<?php
/**
 * This class is used for setting ModulePrefs from code. You can also use the "app.yml" file to do this.
 * 
 * {@link http://code.google.com/apis/gadgets/docs/reference.html#Moduleprefs_Ref The <ModulePrefs> section in the XML file specifies characteristics of the gadget, such as title, author, preferred sizing, and so on. }
 * @package    gadgets
 * @author     Daniel Botelho <botelho.daniel@gmail.com>
 */
class ModulePrefs
{
  /**
   * This Method allows you to set the aplication Title.
   * "Optional string that provides the title of the gadget. This title is displayed in the gadget title bar on iGoogle. If this string contains user preference substitution variables and you are planning to submit your gadget to the content directory, you should also provide a directory_title for directory display."
   * @param string The title 
   */	
  public static function setTitle($title)
  {
  	ModulePrefs::set('title',$title);
  }
  
  /**
   * This Method allows you to change the thumbnail
   * 
   * "ptional string that gives the URL of a gadget thumbnail. This must be an image on a public web site that is not blocked by robots.txt. PNG is the preferred format, though GIF and JPG are also acceptable. Gadget thumbnails should be 120x60 pixels. For more discussion of thumbnail guidelines, see Publishing to the Content Directory."
   * @param string The thumbnail of the app
   */	
  public static function setThumbnail($thumbnail)
  {
  	ModulePrefs::set('thumbnail',$thumbnail);
  }
  
  /** 
   * This Method allows you to change the Authors email
   * 
   * Optional string that provides the gadget author's email address. You can use any email system, but you should not use a personal email address because of spam. One approach is to use an email address of the form helensmith.feedback+coolgadget@gmail.com in your gadget spec. 
   * @param string The author email of the app
   */	
  public static function setAuthorEmail($author_email)
  {
  	ModulePrefs::set('author_email',$author_email);
  }
  
  /**
   * This Method allows you to set the aplications Author.
   * 
   * "Optional string that lists the author of the gadget."
   * @param string The author of the app
   */	
  public static function setAuthor($author)
  {
  	ModulePrefs::set('author',$author);
  }
  
  /**
   * This Method allows you to set the aplication Description.
   * 
   * "Optional string that describes the gadget."
   * @param string The description
   */	
  public static function setDescription($description)
  {
  	ModulePrefs::set('description',$description);
  }
  
  /**
   * This Method allows you to set any key value from ModulePrefs.
   * 
   * @param string $key 
   * @param string $value 
   */	
  public static function set($key,$value)
  {
  	$configs = sfConfig::getAll();
  	$configs['app_opensocial_module_prefs'][$key] = $value;
  	sfConfig::add($configs);
  }
}